<?php
/**
 * User: wufeng
 * Date: 2019/5/15
 * Time: 13:52
 */
namespace app\admin_app\service;

use app\admin_app\model\RobotDeviceModel;
use app\common\service\BaseService;

class StationRobotService extends BaseService
{
	/**
	 * 设备列表
	 * User: wufeng
	 * Date: 2019/5/15
	 *
	 * @param $params
	 * @return array
	 */
	public function robotDeviceLists($params)
	{
		try {
			$where = [];
			xtc_get_user_data_privilege($where, 'B1,C1');
			$this->data = (new RobotDeviceModel(['bid' => $this->bid]))
				->where($where)
				->field('device_number,resource_path')
				->select()
			;
		} catch (\Exception $e) {
			$this->errorMessage($e, $params);
		}

		return $this->return;
	}

	/**
	 * 获取购物二维码图片接口
	 * User: wufeng
	 * Date: 2019/5/15
	 *
	 * @param $params
	 * @return array
	 */
	public function getCode($params)
	{
		try {
			$where = [];
			$where['device_number'] = $params['device_number'];
			xtc_get_user_data_privilege($where, 'B1,C1');
			$this->data = (new RobotDeviceModel(['bid' => $this->bid]))
				->where($where)
				->field('device_number,resource_path')
				->find()
			;
		} catch (\Exception $e) {
			$this->errorMessage($e, $params);
		}

		return $this->return;
	}
}